package com.one.common.manager.imagepreview;

/**
 * Author: zhulunjun
 * Email: zhulunjun@qq.com
 * CreateDate: 2018/12/21 13:57
 * Description：图片预览管理类
 **/
public class ImagePreviewManager {

    private static IImagePreview innerChooser;
    private static IImagePreview externalLoader;

    public static void setPreviewer(IImagePreview chooser) {
        if (externalLoader == null && chooser != null) {
            externalLoader = chooser;
        }
    }

    public static IImagePreview getPreviewer() {
        if (innerChooser == null) {
            synchronized (IImagePreview.class) {
                if (innerChooser == null) {
                    if (externalLoader != null) {
                        innerChooser = externalLoader;
                    } else {
                        innerChooser = new DefaultPreview();
                    }
                }
            }
        }
        return innerChooser;
    }
}
